package com.shadow.mall.fulfill.remote.dubbo;


import com.shadow.mall.fulfill.exception.FulfillBizException;
import com.shadow.mall.fulfill.remote.WmsService;
import com.shadow.mall.wms.api.WmsApi;
import com.shadow.mall.wms.domain.PickDTO;
import com.shadow.mall.wms.domain.PickGoodsRequest;
import com.shadow.mall.common.core.JsonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

/**
 * wms服务远程接口
 *
 *
 * @version 1.0
 */
@Component
public class WmsRemote {


    /**
     * 库存服务
     */
//    @Autowired
//    private WmsApi wmsApi;
    @Autowired
    WmsService wmsService;


    /**
     * 捡货
     */
    public PickDTO pickGoods(PickGoodsRequest request) {
        JsonResult<PickDTO> jsonResult = wmsService.pickGoods(request);
        if (!jsonResult.getSuccess()) {
            throw new FulfillBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
        return jsonResult.getData();
    }

    /**
     * 取消捡货
     */
    public void cancelPickGoods(String orderId) {
        JsonResult<Boolean> jsonResult = wmsService.cancelPickGoods(orderId);
        if (!jsonResult.getSuccess()) {
            throw new FulfillBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
    }

}
